package customer_manage;

import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import customer_manage_analysis_command.AnalysisCommandString;
import customer_manage_database.Init;
import customer_manage_function_implementation.AddCustomer;
import customer_manage_function_implementation.DeleteCustomer;
import customer_manage_function_implementation.LookOverCustomer;

public class customer_manage_test {
	private static AnalysisCommandString ac;
	private static AddCustomer addc;
	private static DeleteCustomer dc;
	private static LookOverCustomer loc;
	private static Init init;
	
	@BeforeClass
	public static void init(){
		ac=new AnalysisCommandString();
		addc=new AddCustomer();
		dc=new DeleteCustomer();
		loc=new LookOverCustomer();	
		init=new Init();
	}
	
	@Test//测试命令字符串解析
	public void analysisCommandTest(){
		char a=ac.getMenu("Lname:jkfdjkf");
		char b=ac.getMenu("OName");
		String[] str=ac.dealParameter("Aid:9,name:kllkl,sex:0");
		for (int i = 0; i < str.length; i++) {
			System.out.println(str[i]);
		}
		Assert.assertTrue(a=='L');
		Assert.assertTrue(b=='O');
		
	}
	@Test  //测试查看功能
	public void lookOverTest(){
		loc.showAllCustomers(init.clist);
		loc.checkWithName("Bob", init.clist);
	}
	@Test  //测试添加功能
	public void addCustomerTest(){
		String[] str1={"id:11","name:fdfd","sex:0"};
		addc.addCustomer(str1, init.clist);
		loc.showAllCustomers(init.clist);
	}
	@Test  //测试删除功能
	public void deleteCustomerTest(){
		String[] str2={"9"};
		dc.deleteCustomer(str2, init.clist);
		loc.showAllCustomers(init.clist);
	}

}
